# crawler/models.py
from django.db import models
import django.utils.timezone as timezone
from user.models import UserProfile

class City(models.Model):


	id = models.AutoField(primary_key=True, editable=False)
	name = models.CharField(verbose_name='城市',null=True,max_length=255)
	year = models.CharField(verbose_name='年份',null=True,max_length=255)
	avg_top_temperature = models.DecimalField(verbose_name='最高温度均值',null=True,max_digits=4,decimal_places=2)
	avg_low_temperature = models.DecimalField(verbose_name='最低温度均值',null=True,max_digits=4,decimal_places=2)
	avg_temperature = models.DecimalField(verbose_name='温度均值',null=True,max_digits=4,decimal_places=2)

	class Meta:
		verbose_name = '城市表'
		verbose_name_plural = verbose_name


class CityData(models.Model):


	id = models.AutoField(primary_key=True, editable=False)
	publish_time = models.DateTimeField(verbose_name='日期',auto_now_add=True)
	week = models.CharField(verbose_name='星期',null=True,max_length=255)
	top_temperature = models.IntegerField(verbose_name='最高温度',default=0)
	low_temperature = models.IntegerField(verbose_name='最低温度',default=0)
	weather = models.CharField(verbose_name='天气',max_length=50, null=True)
	wind_direction = models.CharField(verbose_name='风向',max_length=50, null=True)
	city = models.ForeignKey("City", verbose_name='城市表', on_delete=models.SET_NULL, null=True)

	class Meta:
		verbose_name = '城市数据表'
		verbose_name_plural = verbose_name


class CityReview(models.Model):


	id = models.AutoField(primary_key=True, editable=False)
	add_time = models.DateTimeField(verbose_name='日期',auto_now_add=True)
	city = models.ForeignKey("City", verbose_name='城市表', on_delete=models.SET_NULL, null=True)
	content = models.CharField(verbose_name='评论内容', max_length=255)
	user = models.ForeignKey(UserProfile, verbose_name='用户表', on_delete=models.SET_NULL, null=True)

	class Meta:
		verbose_name = '留言表'
		verbose_name_plural = verbose_name